package com.system.service.impl;

import com.system.mapper.SysPermissionMapper;
import com.system.model.SysPermission;
import com.system.service.SysPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysPermissionServiceImpl implements SysPermissionService {
    @Autowired
    private SysPermissionMapper sysPermissionMapper ;

    /**
     * 全查权限列表
     * @return
     */
    @Override
    public List<SysPermission> queryAllSysPermission() {
        List<SysPermission> sysPermissionList = sysPermissionMapper.queryAllSysPermission();
        return sysPermissionList;
    }

    /**
     * 添加权限信息
     * @param sysPermission
     * @return
     */
    @Override
    public int sysPermissionAdd(SysPermission sysPermission) {
        int i = sysPermissionMapper.insertSelective(sysPermission);
        return i;
    }

    /**
     * 根据id查询权限信息
     * @param sysPermissionIdStr
     * @return
     */
    @Override
    public SysPermission sysPermissionUpdateUI(String sysPermissionIdStr) {
        SysPermission sysPermission_db = sysPermissionMapper.selectByPrimaryKey(Integer.parseInt(sysPermissionIdStr));
        return sysPermission_db;
    }

    /**
     * 修改权限信息
     * @param sysPermission
     * @return
     */
    @Override
    public int sysPermissionUpdate(SysPermission sysPermission) {
         int i = sysPermissionMapper.updateByPrimaryKeySelective(sysPermission);
        return i;
    }

    /**
     * 删除权限信息
     * @param sysPermissionIdStr
     * @return
     */
    @Override
    public int sysPermissionDelete(String sysPermissionIdStr) {
        int i = sysPermissionMapper.deleteByPrimaryKey(Integer.parseInt(sysPermissionIdStr));
        return i;
    }

    @Override
    public List<SysPermission> queryXZSysPermissionByRoleId(int sysRoleId) {
        List<SysPermission> list = sysPermissionMapper.queryXZSysPermissionByRoleId(sysRoleId);
        return list;
    }
}
